package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.CourseType;
import com.hl.sfzy.entity.Fm;
import com.hl.sfzy.mapper.CourseMapper;
import com.hl.sfzy.mapper.CourseTypeMapper;
import com.hl.sfzy.service.CourseTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CourseTypeServiceImpl implements CourseTypeService {

    @Autowired
    private CourseTypeMapper courseTypeMapper;

    @Override
    public int removeByPrimaryKey(Long id) {
        return courseTypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int add(CourseType record) {
        return courseTypeMapper.insert(record);
    }

    @Override
    public CourseType findByPrimaryKey(Long id) {
        return courseTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int editByPrimaryKey(CourseType courseType) {
        return courseTypeMapper.updateByPrimaryKey(courseType);
    }

    @Override
    public int removeBatch(List<Long> ids) {
        return courseTypeMapper.deleteBatch(ids);
    }

    @Override
    public List<CourseType> find(int pageNum, int pageSize) {
        return courseTypeMapper.select(pageNum, pageSize);
    }

    @Override
    public PageInfo<CourseType> findByPage(int pageNum, int pageSize, CourseType courseType) {
        PageHelper.startPage(pageNum, pageSize);
        List<CourseType> list = courseTypeMapper.selectByPage(pageNum, pageSize, courseType);
        PageInfo<CourseType> pageInfo = new PageInfo<>(list);
        return pageInfo;

    }
}
